package funjava;

/**
 * Created by judasnow on 5/17/16.
 */
class Point {
    int x;
    int y;

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    /**
     * 构造函数不能有返回值 任何被标记有返回值的方法都不再被看作是 构造函数
     */
    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

class LabeledPoint extends Point {

    String label;

    public String getLabel() {
        return label;
    }

    public LabeledPoint(String label, int x, int y) {
        super(x, y);
        this.label = label;
    }

    @Override
    public String toString() {
        return this.getClass().getName();
    }
    
    public boolean equals(Point p) {
        if (p.getX() == this.getX() && p.getY() == this.getY()) {
            return true;
        } else {
            return false;
        }
    }
}

public class C4_1 {
    public static void main (String[] args) {
        LabeledPoint lp = new LabeledPoint("source", 0, 0);
        System.out.println(lp);
    }
}
